import $store from '@/store/index.js';
import msgSqlite from "@/sqlite_services/msg.js"
//群消息编辑
const handle = async(data)=>{
	try{
		await msgSqlite.updateMessageById(data.msg_id, {
			content_text:JSON.stringify(data.content_text),
		})
		const activeChatUuid = $store.state.chat.chatInfo && $store.state.chat.chatInfo.uuid || ''; // 访问根级状态的chatInfo
		
		//更新会话
		$store.dispatch('editMsgSession', {
			chat_id: data.target_id,
			msg_id: data.msg_id,
			content_text: data.content_text
		})
		
		if(data.target_id == activeChatUuid){
			uni.$emit('onMessageControls', {
				type:'msg_edit',
				data:{
					msg_id: data.msg_id,
					content_text: data.content_text
				}
			})
		}
	}catch(e){
		
	}
}
export default handle